import {ColumnsType} from "antd/es/table";
import {Space} from "antd";
import {Link} from "react-router-dom";
import {ellipsisHandler} from "../util/ColumnsUtil";
import {SecurityRole} from "../type/SecurityRole";
import InitHandler from "../global/InitHandler";

const IconFont = InitHandler.getInstance().getIconFont() ;
const roleColumns: ColumnsType<SecurityRole> = [
    {
        dataIndex: 'index',
        title: '序号' ,
        width: 60,
        align: "center" ,
        render: (value, record, index) => {
            return <strong> {index + 1} </strong> ;
        }
    },
    {
        key: 'id',
        dataIndex: 'id' ,
        title: '用户编号',
        width: 110,
        align: "center" ,
        ellipsis: {showTitle: false},
        render: ellipsisHandler
    },
    {
        key: 'authority',
        dataIndex: 'authority' ,
        title: '角色定义',
        width: 150,
        // align: "center" ,
        ellipsis: {showTitle: false},
        render: (value,record) => <Link to={"./details"} state={record}>{value}</Link>
    },
    {
        key: 'explain',
        dataIndex: 'explain' ,
        title: '角色说明',
        width: 150,
        // align: "center" ,
        ellipsis: {showTitle: false},
        render: ellipsisHandler
    },
    {
        key: 'icon',
        dataIndex: 'icon' ,
        title: '图标',
        width: 60,
        align: "center" ,
        render: (value, record) => {
            return <IconFont type={record.icon} /> ;
        }
    },
    {
        key: 'weight',
        dataIndex: 'weight' ,
        title: '角色权重',
        width: 100,
        align: "center" ,
        ellipsis: {showTitle: false},
        render: ellipsisHandler
    },
    {
        key: 'order',
        dataIndex: 'order' ,
        title: '数据排序字段',
        width: 100,
        align: "center" ,
        ellipsis: {showTitle: false},
        render: ellipsisHandler
    },
    {
        key: 'remark',
        dataIndex: 'remark' ,
        title: '数据备注信息',
        // width: 100,
        align: "center" ,
        ellipsis: {showTitle: false},
        render: ellipsisHandler
    },
    {
        key: 'option',
        title: '角色操作',
        dataIndex: 'option' ,
        align: "center",
        width: 170,
        render: (value, record, index  ) => {
            return (
                <Space size={8}>
                    <Link key={"role-update"} to={'./update/' + record.id}>更新</Link>
                    <Link key={"role-authority"} to={'./authority'} state={record}>授权</Link>
                    <Link style={{color:'red'}} key={"role-delete"} to={`./delete/${record.id}/${record.authority}`}>删除</Link>
                </Space>
            );
        }
    }

] ;
export default roleColumns ;
